import { createSlice } from "@reduxjs/toolkit";

const userSlice = createSlice({
  name: "userSlice",
  initialState: {
    userInfor: JSON.parse(localStorage.getItem("userInfor") || "{}"),
  },
  reducers: {
    setUserInfor(state, { payload }) {
      state.userInfor = payload;
      localStorage.setItem("userInfor", JSON.stringify(state.userInfor));
    },
  },
});
export const { setUserInfor } = userSlice.actions;
export default userSlice.reducer;
